﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data ;
using System.Data .SqlClient ;
using dhDataAcess.orderLinqDAL ;

namespace dhDataAcess.orderDAL
{
   public  class custTypeDAL
    {
       string tableName = "custType";
       private SqlConnection conn = null;
       private SqlTransaction tran = null;
       public custTypeDAL( SqlTransaction _transction,SqlConnection _conn)
       {
           conn = _conn;
           tran = _transction;
         
       }
       /// <summary>
       /// 插入客户类别表数据
       /// </summary>
       /// <param name="deptRow"></param>
       /// <returns></returns>
       public int custTypeInsert(custTypeModel row)
       {
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = conn;
           cmd.CommandType = CommandType.Text;
           string insertstr = baseBLL.dTableColumnRead.insertSqlStr(tableName).ToString();
           SqlParameter[] para = {
                                   new SqlParameter ("@mark",row .mark ),
                                   new SqlParameter ("@updateUser",row .updateUser),
                                   new SqlParameter ("@updateDate",row .updateDate),
                                   new SqlParameter ("@createUser",row .createUser),
                                   new SqlParameter ("@createDate",row .createDate),
                                   new SqlParameter ("@cTypeParent",row .cTypeParent),
                                   new SqlParameter ("@ctypeMark",row .ctypeMark),
                                   new SqlParameter ("@cType",row .cType)
                                  };
           cmd.Parameters.AddRange(para);
           cmd.CommandText = insertstr;
           cmd.Transaction = tran ;
           int i = cmd.ExecuteNonQuery();
           return i;
          
           
       }
       /// <summary>
       /// 更新客户类别表数据
       /// </summary>
       /// <param name="deptRow"></param>
       /// <returns></returns>
       public int custTypeUpdate(custTypeModel row)
       {
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = conn;
           cmd.CommandType = CommandType.Text;
           string updatestr = baseBLL.dTableColumnRead.updateSqlStr(tableName).ToString();
           SqlParameter[] para = {
                                   new SqlParameter ("@mark",row .mark ),
                                   new SqlParameter ("@updateUser",row .updateUser),
                                   new SqlParameter ("@updateDate",row .updateDate),
                                   new SqlParameter ("@createUser",row .createUser),
                                   new SqlParameter ("@createDate",row .createDate),
                                   new SqlParameter ("@cTypeParent",row .cTypeParent),
                                   new SqlParameter ("@ctypeMark",row .ctypeMark),
                                   new SqlParameter ("@cType",row .cType)
                                  };
           cmd.Parameters.AddRange(para);
           cmd.CommandText = updatestr;
           cmd.Transaction = tran;
           int i = cmd.ExecuteNonQuery();
           return i;
       }
       /// <summary>
       /// 删除一行客户类别表数据
       /// </summary>
       /// <param name="deptRow"></param>
       /// <returns></returns>
       public int custTypeListDel(string cType)
       {
           SqlCommand cmd = new SqlCommand();
           cmd.Connection = conn;
           cmd.CommandType = CommandType.Text;
           string deletestr = baseBLL.dTableColumnRead.delSqlStr(tableName).ToString();
           SqlParameter[] para = {
                                   new SqlParameter ("@cType",cType)
                                  };
           cmd.Parameters.AddRange(para);
           cmd.CommandText = deletestr;
           cmd.Transaction = tran;
           int i = cmd.ExecuteNonQuery();
           return i;
       }
    }
}
